package com.young.shop.api.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.young.shop.pojo.entity.TbMessage;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2021-01-27
 */

@Repository
public interface TbMessageMapper extends BaseMapper<TbMessage> {

    /**
     * 查找 对应接收者 的消息
     * @param recipient
     * @return
     */
    List<TbMessage> selectListTbMessageByRecipient(String recipient);

    /**
     * 查找 对应发送者 的消息
     * @param sender
     * @return
     */
    List<TbMessage> selectListTbMessageBySender(String sender);

    /**
     * 存入一条消息到数据库
     * @param tbMessage
     * @return
     */
    int insertOneMessage(TbMessage tbMessage);

    int insertOMessageReadStateIs1(TbMessage tbMessage);

    /**
     * 修改 对应 id 的消息状态为已读
     * @param id
     * @return
     */
    int updateReadStateTo1ById(Integer id);



}
